<template>
	<view>
		<u-popup v-model="subscribeWechatOfficialAccountPopupShowStatus" :z-index="19999" :mask-close-able="false" mode="center" width="80%" :border-radius="16">
			<view class=" relative bg">
				<u-image width="100%" mode="widthFix" :border-radius="15" src="https://resource.lanbaozixun.com/uploads/images/20240625183633322cd5281.jpg"></u-image>
					<view class="mt30 u-text-center" >
						<u-icon name="close-circle" color="#FFF" size="60" @click="refreshSubscribeStatus"></u-icon>
					</view>
			</view>
		</u-popup>
	</view>
</template>

<script>
	import {
		toLogin
	} from "@/utils/login";
	import {getService} from "@/api/app"
	import {isWeixinClient} from "@/utils/tools"
	import {wheteFollowWechatOfficialAccount} from "@/api/user"
	export default {
		data() {
			return {
				subscribeWechatOfficialAccountPopupShowStatus:false
			};
		},
		created() {
			this.refreshSubscribeStatus();
		},
		methods:{
			async refreshSubscribeStatus(){
				const _this = this;
				if(isWeixinClient()){
					if (!this.isLogin) return toLogin();
					let {code,data} = await wheteFollowWechatOfficialAccount();
					if(code == 1 && data.subscribe == 0){
						_this.qrCode = data.qr_code;
						_this.$u.toast('请关注公众号');
						_this.subscribeWechatOfficialAccountPopupShowStatus = true;
						return false;
					}else{
						_this.subscribeWechatOfficialAccountPopupShowStatus = false;
						_this.$emit("focusCompletion")
					}
				}else{
					_this.subscribeWechatOfficialAccountPopupShowStatus = false;
					_this.$emit("focusCompletion")
				}
			},
		}
	}
</script>

<style lang="scss">
	
.qrCode{
		width: 100%;
		display: block;
	}
</style>